<%@page import="java.util.Map"%>
<%@page import="com.hospital.util.DbUtil"%>
<%@page import="com.hospital.util.Pagination"%>
<%@page import="com.hospital.model.*"%>
<%@page import="java.util.List"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="images/main.css" rel="stylesheet" type="text/css" />
<link  href="../css/style.css" rel="stylesheet" type="text/css" />
<title></title>
</head>
<body>
	<!-- TOP START -->
	<jsp:include page="right_top.jsp"></jsp:include>
	<div id="right_font">
		<img src="images/main_14.gif" /> 您现在所在的位置：首页 &rarr; 统计报表查看 &rarr; <span
			class="bfont">病人充值收入汇总</span>
	</div>
	<!-- TOP END -->
	
	<!-- MAIN START -->
		<form name="form" id="form">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
							<!-- table context start -->
							<table style="margin-top: 10px; margin-left:350px;" cellpadding="0" cellspacing="0" border="0" width="40%">
								<tr height="30px;">
									<td colspan="2" align="center" style="font-size:30px;">&nbsp; 
										病 人 充 值 收 入 情 况  
								</td>
							</tr>
					</table>
					<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9">
						<tr>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<strong><span class="STYLE1">编号</span></strong>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<strong><span class="STYLE1">充值ID</span></strong>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<strong><span class="STYLE1">病人姓名<br></span></strong>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<strong><span class="STYLE1">充值金额<br></span></strong>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<strong><span class="STYLE1">充值时间<br></span></strong>
								</div>
							</td>
						<%
							/**
							 * 分页begin
							 */
							 
							double totalmoney = 0.0;
							final int pageSize = 15; // 一页显示 15 条记录
		
							int pageNum = 1; // 当前页数
							int pageCount = 1; // 总页数
							int recordCount = 0; // 总记录数
							String strAbsPath = application.getRealPath(request.getRequestURI()); // 获得当前文件的绝对路径名
							int endIndex = strAbsPath.length();
							int beginIndex = strAbsPath.lastIndexOf("\\") + 1;
							String pageUrl = strAbsPath.substring(beginIndex, endIndex); // 获取当前文件名，如：xxx.jsp,或者 xxx.html
							try {
								// 从地址栏参数取当前页数
								if (request.getParameter("pageNum") == null) {
									pageNum = 1;
								} else {
									pageNum = Integer.parseInt(request.getParameter("pageNum"));
								}
							} catch (Exception e) {
								e.printStackTrace();
							}
							recordCount = DbUtil.getCount("t_patient_money");
							// 计算总页数
							pageCount = (recordCount + pageSize - 1) / pageSize;
							// 本页从 startRecord 行开始
							int startRecord = (pageNum - 1) * pageSize;
							/**
							 * 分页end
							 */
							int num = 1;
							String sql = "select * from t_patient_money order by id desc limit "+ startRecord + " ," + pageSize;	
							List<Map<String, Object>> list = DbUtil.find(sql);
							Map<String, Object> map = null;
							for (int i = 0; i < list.size(); i++) {
								map = (Map<String, Object>)list.get(i);
						%>
						<tr>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<span class="STYLE3"><%=num++%></span>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<span class="STYLE3"><%=map.get("id")%></span>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<span class="STYLE3"><%=map.get("account")%></span>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<span class="STYLE3"><%=map.get("addmoney")%></span>
									<%
										 if(!map.get("addmoney").equals("null")){
											String money = (String)map.get("addmoney");
											totalmoney = totalmoney + Double.parseDouble(money);
										} 
									%>
								</div>
							</td>
							<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<span class="STYLE3"><%=map.get("addtime")%></span>
								</div>
							</td>
						<%
							}
						%>
					</table>
					<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9">
						<td height="22" bgcolor="#FFFFFF">
								<div align="center">
									<strong><span class="STYLE1">总金额 :<%=totalmoney%><br></span></strong>
								</div>
							</td>
					</table>
				<!-- table context end -->
				</td>
			</tr>
			<tr>
				<td height="35">
					<!-- page start -->
					<table width="100%" border="0" cellspacing="0" cellpadding="1">
						<tr>
							<td width="75%" valign="top" class="STYLE1">
								<div align="right">
									<%=Pagination.getPagination(pageNum, pageCount, recordCount,pageUrl)%>&nbsp;&nbsp;
								</div>
							</td>
						</tr>
					</table>
					<!-- page end -->
				</td>
			</tr>
		</table>
	</form>
	<table style="margin-top: 30px; margin-left:350px;" cellpadding="0" cellspacing="0" border="0" width="40%">
			<tr height="30px;">
				<td colspan="2" align="center">
					<input type="button" value="打印" onclick="window.print();"/>&nbsp;&nbsp;
				</td>
			</tr>
		</table>
</body>
</html>
